import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  View,
  ScrollView,
  Image,
  Animated,
  TouchableOpacity
} from 'react-native';
import styles from './settingIndexStyle';

import EasemobChat from '../global/EasemobChat';
import ToastTip from '../global/ToastTip';
import api from '../../services/api';

class VersionUpdateIntro extends Component {
    constructor(props) {
		super(props);

		this.state = {
            scrollY: new Animated.Value(0),
            versionInfo:{}
		};
	}

    async componentWillMount() {
        // 通过多版本介绍里面的参数获取id
        let {versionNum} = this.props;
        console.log(versionNum,'asdasdasdasd');
        // this._retrieveDetails();
        let res = await api.post('/version/android/getByVersionNum',{versionNum});
        console.log(res,'dsgfxghcvjhb');
        this.setState({versionInfo:res.data})
    }
    
    renderMarkList = (c) => {
        // c = c.replace(/<p>/g, "");
        // c = c.replace(/<br>/g, "");
        let b = c = c.replace(/&nbsp;/g, "");
        // c = c.replace(/<\/p>/g, "");


        // c = c.replace(/&nbsp;/g, "");
            // c = c.replace(/<br>/g, "");
        b = b.replace(/&lt;/g,"<");
        b = b.replace(/&gt;/g,'>');
        // c = c.replace(/<[^>]*>/g,"");
        b = b.split(/<[^>]*>/g);
        if (!b[b.length - 1]) {
            b.pop();
        }
        return b.map((item, index) => {
            if(item){
                return <Text style={{color: "#7b7b7b",fontSize: 13,}} key={index}>{item}</Text>
            }
        })
    }

    render() {
        let {versionInfo} = this.state;
        return (
            <View style={styles.container}>
                <ScrollView
                    style={styles.scrollContainer}
                    scrollEventThrottle={16}>
                    
                    <View style={[styles.toolsContainer,{height:300,padding:15}]}>
                        <View style={{display:'flex'}}>{this.renderMarkList(versionInfo.remark||'')}</View>
                    </View>
                </ScrollView>
            </View>     
        );
    }
}

var connectHelper = require('../../services/connectHelper');
VersionUpdateIntro = connectHelper(state => state)(VersionUpdateIntro);

module.exports = VersionUpdateIntro;
